using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Toon.Models.Characters;

namespace Toon.Models.Tests.Characters
{
	
    public partial class PossessionTests
    {


        
        
        [TestMethod]
        public void PossessionTests_Property_Name_NotifyPropertyChanged_SelfAssign ()
        {
            var objectUnderTest = CreateObject();
            var events = new List<PropertyChangedEventArgs>();
            ((INotifyPropertyChanged)objectUnderTest).PropertyChanged += (s, e) => events.Add(e);


			//Setting the value to the current value should always work and not raise any events
			var originalValue = objectUnderTest.Name;
			objectUnderTest.Name = originalValue;
			Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");
        }    
        
        
        
        [TestMethod]
        public void PossessionTests_Property_Name_NotifyPropertyChanged ()
        {
            var objectUnderTest = CreateObject();
            var events = new List<PropertyChangedEventArgs>();
            ((INotifyPropertyChanged)objectUnderTest).PropertyChanged += (s, e) => events.Add(e);

            //perform a self-assignment to avoid duplicating the above test
   			var originalValue = objectUnderTest.Name;
			objectUnderTest.Name = originalValue;

        
            
            events.Clear();
            try
            {
                System.String expectedValue = null;
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "1";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "x";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = ",";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "123";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "abc";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "1,2,3";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "a,b,c";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "1;2;3";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "a;b;c";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "http://test.com";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "test@test.com";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Name);
                objectUnderTest.Name = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Name"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
        
        }    
        
        
        
        [TestMethod]
        public void PossessionTests_Property_Notes_NotifyPropertyChanged_SelfAssign ()
        {
            var objectUnderTest = CreateObject();
            var events = new List<PropertyChangedEventArgs>();
            ((INotifyPropertyChanged)objectUnderTest).PropertyChanged += (s, e) => events.Add(e);


			//Setting the value to the current value should always work and not raise any events
			var originalValue = objectUnderTest.Notes;
			objectUnderTest.Notes = originalValue;
			Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");
        }    
        
        
        
        [TestMethod]
        public void PossessionTests_Property_Notes_NotifyPropertyChanged ()
        {
            var objectUnderTest = CreateObject();
            var events = new List<PropertyChangedEventArgs>();
            ((INotifyPropertyChanged)objectUnderTest).PropertyChanged += (s, e) => events.Add(e);

            //perform a self-assignment to avoid duplicating the above test
   			var originalValue = objectUnderTest.Notes;
			objectUnderTest.Notes = originalValue;

        
            
            events.Clear();
            try
            {
                System.String expectedValue = null;
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "1";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "x";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = ",";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "123";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "abc";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "1,2,3";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "a,b,c";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "1;2;3";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "a;b;c";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "http://test.com";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
            
            events.Clear();
            try
            {
                System.String expectedValue = "test@test.com";
                var valueChanged = !Object.Equals(expectedValue, objectUnderTest.Notes);
                objectUnderTest.Notes = expectedValue;
                
            	if (valueChanged)
					Assert.IsTrue(events.Any(e => e.PropertyName == "Notes"));
				else
					Assert.IsTrue(events.Count() == 0, "No change events should have been raised, the property's value didn't change.");

            }
            catch (ArgumentException)
            {
                //OK
                return;
            }
            
        
        }    
        
    }
}

